//
//  SmsCloudTableSearchResultCell.m

#import "SmsCloudTableSearchResultCell.h"

static NSString * SmsCloudTableSearchResultCellId = @"SmsCloudTableSearchResultCellId";
@interface SmsCloudTableSearchResultCell()
@property (nonatomic,strong) UIImageView *smsCloudImgView;
@property (nonatomic,strong) UILabel *smsCloudHeadNameLab;
@property (nonatomic,strong) UILabel *smsCloudHeadNumLab;
@end
@implementation SmsCloudTableSearchResultCell
+ (instancetype)smsCloudTableSearchResultCell:(UITableView *)tableView{
    SmsCloudTableSearchResultCell * smsCloudTableSearchResultCell = [tableView dequeueReusableCellWithIdentifier:SmsCloudTableSearchResultCellId];
    if (!smsCloudTableSearchResultCell) {
        smsCloudTableSearchResultCell = [[SmsCloudTableSearchResultCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SmsCloudTableSearchResultCellId];
    }
    smsCloudTableSearchResultCell.backgroundColor = [UIColor clearColor];
    smsCloudTableSearchResultCell.selectionStyle = UITableViewCellSelectionStyleNone;
    smsCloudTableSearchResultCell.accessoryType = UITableViewCellAccessoryNone;
    return smsCloudTableSearchResultCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self smsCloudInitView];
    }
    return self;
}
- (void)smsCloudInitView{
    UIView * smsCloudBgView = [[UIView alloc] init];
    smsCloudBgView.backgroundColor = [SmsCloudHead SmsCloudColorHexString:@"##0087FF" withAlpha:0.1];
    smsCloudBgView.layer.cornerRadius = [SmsCloudHead SmsCloudScreewRatio:16];
    smsCloudBgView.clipsToBounds = YES;
    [self.contentView addSubview:smsCloudBgView];
    [smsCloudBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([SmsCloudHead SmsCloudScreewRatio:24]));
        make.right.equalTo(@(-[SmsCloudHead SmsCloudScreewRatio:24]));
        make.top.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
        make.bottom.equalTo(@(-[SmsCloudHead SmsCloudScreewRatio:20]));
    }];
    self.smsCloudImgView = [[UIImageView alloc] init];
    self.smsCloudImgView.image = [SmsCloudHead SmsCloudImageNamed:@"smsCloudSearchHead"];
    [smsCloudBgView addSubview:self.smsCloudImgView];
    [self.smsCloudImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([SmsCloudHead SmsCloudScreewRatio:40]));
        make.centerY.equalTo(smsCloudBgView);
        make.width.equalTo(@([SmsCloudHead SmsCloudScreewRatio:44]));
        make.height.equalTo(@([SmsCloudHead SmsCloudScreewRatio:44]));
    }];
    self.smsCloudHeadNameLab = [[UILabel alloc] init];
    self.smsCloudHeadNameLab.font = [UIFont systemFontOfSize:[SmsCloudHead SmsCloudScreewRatio:34] weight:UIFontWeightRegular];
    self.smsCloudHeadNameLab.textColor = [SmsCloudHead SmsCloudColorHexString:@"#222222"];
    [smsCloudBgView addSubview:self.smsCloudHeadNameLab];
    [self.smsCloudHeadNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.smsCloudImgView.mas_right).offset([SmsCloudHead SmsCloudScreewRatio:23]);
        make.centerY.equalTo(smsCloudBgView);
        make.height.equalTo(@([SmsCloudHead SmsCloudScreewRatio:48]));
    }];
    self.smsCloudHeadNumLab = [[UILabel alloc] init];
    self.smsCloudHeadNumLab.font = [UIFont systemFontOfSize:[SmsCloudHead SmsCloudScreewRatio:24] weight:UIFontWeightMedium];
    self.smsCloudHeadNumLab.textColor = [SmsCloudHead SmsCloudColorHexString:@"#222222"];
    [smsCloudBgView addSubview:self.smsCloudHeadNumLab];
    [self.smsCloudHeadNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-[SmsCloudHead SmsCloudScreewRatio:193]));
        make.centerY.equalTo(smsCloudBgView);
        make.height.equalTo(@([SmsCloudHead SmsCloudScreewRatio:48]));
    }];
    UIButton * smsCloudCopyBtn = [[UIButton alloc] init];
    [smsCloudCopyBtn setBackgroundImage:[SmsCloudHead SmsCloudImageNamed:@"smsCloudCopy"] forState:UIControlStateNormal];
    [smsCloudCopyBtn addTarget:self action:@selector(smsCloudCopy) forControlEvents:UIControlEventTouchUpInside];
    [smsCloudBgView addSubview:smsCloudCopyBtn];
    [smsCloudCopyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-[SmsCloudHead SmsCloudScreewRatio:24]));
        make.centerY.equalTo(smsCloudBgView);
        make.width.equalTo(@([SmsCloudHead SmsCloudScreewRatio:140]));
        make.height.equalTo(@([SmsCloudHead SmsCloudScreewRatio:58]));
    }];
}
- (void)smsCloudCopy{
    NSString *aear = [_smsCloudProductDic objectForKey:@"aear"];
    if(aear.length){
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = aear;
        [SVProgressHUD showInfoWithStatus:@"复制成功"];
    }
}
-(void)setSmsCloudProductDic:(NSDictionary *)smsCloudProductDic{
    _smsCloudProductDic = smsCloudProductDic;
    if(_smsCloudProductDic){
        _smsCloudHeadNameLab.text = [_smsCloudProductDic objectForKey:@"name"];
        _smsCloudHeadNumLab.text = [_smsCloudProductDic objectForKey:@"aear"];
    }
}
@end
